package com.lagou.controller;

import com.lagou.entity.User;
import com.lagou.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * document
 *
 * @author: dcy
 * @date: 2021-10-08 17:08
 * @version: 1.1
 */
@RestController
@RequestMapping(value = "user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    @ResponseBody
    public List<User> list(){
        return userService.list();
    }

    @RequestMapping("/insert")
    public User insert(@RequestBody User user){
        return userService.insert(user);
    }

    @RequestMapping("/update")
    public int update(@RequestBody User user){
        return userService.update(user);
    }

    @RequestMapping("/delete")
    public int delete(int id){
        return userService.delete(id);
    }

}
